package section8;
abstract class Shape{
    protected String name;
    public Shape(String xm){
        name=xm;
        System.out.println("名称:"+name);
    }
    abstract public double getArea();
    abstract public double getLength();
}
class Circle extends Shape{
    private final double PI=3.14;
    private double radius;
    public Circle(String shapeName,double r){
        super(shapeName);
        radius=r;
    }

    @Override
    public double getArea() {
        return PI*radius*radius;
    }

    @Override
    public double getLength() {
        return 2*radius*PI;
    }
}
class Rectangle extends Shape{
    private double width;
    private double heigth;
    public Rectangle(String shapeName,double width,double heigth){
        super(shapeName);
        this.width=width;
        this.heigth=heigth;
    }

    @Override
    public double getArea() {
        return width*heigth;
    }

    @Override
    public double getLength() {
        return 2*(width+heigth);
    }

}
public class App8_10 {
    public static void main(String[] args) {
        Shape rect=new Rectangle("长方形",6.5,12.4);
        System.out.print(";面积="+rect.getArea());
        System.out.print(";周长="+rect.getLength());
        Shape circle=new Circle("圆",12.7);
        System.out.print(";面积="+circle.getArea());
        System.out.print(";周长="+circle.getLength());
    }
}
